﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Upload.ascx.cs" Inherits="JobSeek.Poster.Upload" %>
<script type="text/javascript">

    function showThrobber() {
        $('#throbber').css({
            display: 'block'
        });
    }

    function hideThrobber() {
        $('#throbber').css({
            display: 'none'
        });
    }

    function setFileName(value) {

        $('#tbxFileUploadName').val(value);
    }

</script>
<table class="uploadLogo">
    <tr>
        <td class="column1">
        </td>
        <td>
        </td>
        <td>
            <asp:Panel ID="errorPannel" runat="server" Style="display: none;" Width="400" class="error-message">
            </asp:Panel>
        </td>
        <td>
        </td>
    </tr>
    <tr>
        <td class="column1">
            <label>
                Upload your logo</label>
        </td>
        <td class="column-star">
            <span id="myThrobber" style="display: none" runat="server">
                <img src="../Content/Throbber.gif" style="display: block" id="throbber" width="15"
                    height="15" />
            </span>
        </td>
        <td class="column2">
            <asp:TextBox ID="tbxFileUploadName" runat="server" placeholder="Please select a file"
                class="fileinput-text" ReadOnly="true" ClientIDMode="Static"></asp:TextBox>
            <span class="btn btn-success fileinput-button"><i class="icon-plus icon-white"></i><span>
                Browse...</span>
                <asp:FileUpload ID="AsyncFileUpload1" runat="server" ClientIDMode="Static" onchange="setFileName(this.value);" />
            </span>
            <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="BtnUpload_Click"
                CausesValidation="false" class="btn btn-upload" OnClientClick="showThrobber()" />
        </td>
        <td class="column3" style="text-align: right;">
            &nbsp;
        </td>
    </tr>
    <tr>
        <td class="column1">
        </td>
        <td>
        </td>
        <td>
            <asp:UpdatePanel runat="server" ID="LogosPanel" UpdateMode="Conditional">
                <ContentTemplate>
                    <section>
                        <article class="repeater-wrapper">
                            <ul>
                                <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
                                    <ItemTemplate>
                                        <li>
                                            <section>
                                                <table>
                                                    <tr>
                                                        <td style="width: 75px">
                                                            <asp:Image ID="Image1" ImageUrl='<%#ResolveClientUrl(((String)DataBinder.Eval(Container.DataItem, "logo_url"))) + "?"+ Guid.NewGuid().ToString()%>'
                                                                alt="" runat="server" />
                                                        </td>
                                                        <td style="width: 150px;">
                                                            <label>
                                                                <%#DataBinder.Eval(Container.DataItem, "Name") %>
                                                            </label>
                                                        </td>
                                                        <td>
                                                            <input type="radio" id='<%# DataBinder.Eval(Container.DataItem, "name") %>' name="selected"
                                                                title="<%# ResolveClientUrl(((String)DataBinder.Eval(Container.DataItem, "logo_url"))) + "?" +  Guid.NewGuid().ToString()%>"
                                                                value='<%# DataBinder.Eval(Container.DataItem,"isUsed") %>' onclick="radioSelected(this)" />
                                                            select
                                                        </td>
                                                    </tr>
                                                </table>
                                            </section>
                                        </li>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </ul>
                        </article>
                    </section>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </td>
        <td>
        </td>
    </tr>
    <tr>
        <td>
        </td>
        <td style="text-align: right;" colspan="2">
            &nbsp;
        </td>
        <td>
        </td>
    </tr>
</table>
<asp:HiddenField ID="radioSelectedName" Value="" runat="server" ClientIDMode="Static" />
<asp:UpdatePanel runat="server" ID="CropperUpdatePanel" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Panel runat="server" ID="togglePanel" Style="display: none">
            <table>
                <tr>
                    <td style="width: 303px">
                        <asp:Image ID="imgCurrent" Width="" runat="server" ClientIDMode="Static" />
                    </td>
                    <td>
                        <div id="preview" class="preview" style="width: 200px; height: 200px">
                            <div id="innerPreview" style="overflow: hidden">
                                <img src="#" id="croppedImage" />
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="btnSave" runat="server" Text="Save" ClientIDMode="Static" class="cancel"
                            ValidationGroup="logoValidation" CausesValidation="true" OnClick="btnSave_Click"
                            CssClass="btn btn-save" />
                        <input type="button" class="btn btn-cancel" value="Cancel" id="cancel" />
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <label>
                            Rename your image:
                        </label>
                        <asp:TextBox ID="tbxRenameLogo" runat="server" ValidationGroup="logoValidation" MaxLength="20"></asp:TextBox><asp:RequiredFieldValidator
                            ValidationGroup="logoValidation" ID="RtbxRename" runat="server" ControlToValidate="tbxRenameLogo"
                            ErrorMessage="Please give a name to your image" CssClass="error-message" Style="padding: 4px;"></asp:RequiredFieldValidator>
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>
